﻿using System;
using System.Collections.Generic;
using System.Text;

namespace TSVNAddin.Core
{
	public class CommandProvider
	{
		private readonly CommandFactory m_CommandsFactory;

		public CommandProvider(CommandFactory commandsFactory)
		{
			m_CommandsFactory = commandsFactory;
		}

		public virtual ICommand GetCommand(string commandName)
		{
			CommandDictionary commands = m_CommandsFactory.CreateCommands();

			string[] strArray = commandName.Split('.');
			int lastIndex = strArray.Length - 1;

			string commandTypeName = strArray[lastIndex];
			CommandType commandType = (CommandType)Enum.Parse(typeof(CommandType), commandTypeName);

			return commands[commandType];
		}
	}
}
